package com.isoftstone.demo.common.utils;

import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;

/**
 * @author: yhq
 * @create: 2020-11-20
 * @description:
 **/
public class CommonUtils {
    public static String toDateString(Long date) {
        return new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(new Date(date));
    }

    public static Date toDate(String date) {
        try {
            return new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").parse(date);
        } catch (ParseException e) {
            throw new RuntimeException("日期格式错误");
        }
    }
}
